export const formatTime = () => {
	const date = new Date();
	const year = date.getFullYear();
	const month = date.getMonth() + 1;
	const day = date.getDate();
	const weekDay = ['日', '一', '二', '三', '四', '五', '六'][date.getDay()];
	const hour = date.getHours();
	const minute = date.getMinutes();
	const second = date.getSeconds();
	return {
		date: [year, month, day].map(formatNumber).join('-'),
		time: [hour, minute, second].map(formatNumber).join(':'),
		week: '星期' + weekDay
	};
};
const formatNumber = (n) => {
	const s = n.toString();
	return s[1] ? s : '0' + s;
};
export const createImage = () => {
	// 创建离屏canvas
	const canvas = uni.createOffscreenCanvas({
		type: '2d'
	});
	// 创建一个图片
	const image = canvas.createImage();
	return image;
}
export const createCanvasContext = (width, height) => {
	const canvas = uni.createOffscreenCanvas({
		type: '2d',
		width,
		height
	});
	const context = canvas.getContext('2d');
	return [canvas, context];
}